﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace StudentManagerApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            StudentManager.Instance.Start();


            //timer = new Timer(DoSometing1, "DoSometing", 1000, 1 * 1000);
            //timer1 = new Timer(DoSometing2, "DoSometing", 0, 5 * 1000);
            //timer2 = new Timer(DoSometing3, "DoSometing", 0, 10 * 1000);
            //Console.ReadLine();
        }

        static void DoSometing1(object data)
        {
            MyClass.time++;
            if (MyClass.time % 10 == 0)
            {
                actiona();
            }
            if (MyClass.time % 5 == 0)
            {
                actionb();
            }
            if (MyClass.time % 2 == 0)
            {
                actionc();
            }
        }

        static Action actiona;
        static Action actionb;
        static Action actionc;

        class MyClass
        {
            static MyClass()
            {
                Timer timer = new Timer(DoSometing, "DoSometing", 0, 1000);
                actiona += MyFun1;
                actionb += MyFun2;
                actionc += MyFun3;
            }

            static void DoSometing(object data)
            {
                Console.WriteLine("MyFun1Count:{0}MyFun2Count:{1},MyFun3Count{2}", MyFun1Count, MyFun2Count, MyFun3Count);
                if (MyFun1Count >= 10 && MyFun2Count >= 10 && MyFun3Count >= 10)
                {
                    timer.Dispose();
                }
            }



            static void MyFun1()
            {
                Console.WriteLine("MyFun1");
                MyClass.MyFun1Count++;
            }

            static void MyFun2()
            {
                Console.WriteLine("MyFun2");
                MyClass.MyFun2Count++;
            }

            static void MyFun3()
            {
                Console.WriteLine("MyFun3");
                MyClass.MyFun3Count++;
            }
            public static int time = 0;
            public static int MyFun1Count = 0;
            public static int MyFun2Count = 0;
            public static int MyFun3Count = 0;
        }

    //    static void DoSometing(object data)
    //    {
    //        Console.WriteLine("*");
    //        for (int i = myClass.Students.Count - 1; i >= 0; i--)
    //        {
    //            Field.Instance.DoSport(myClass.Students[i]);
    //            if (myClass.Students[i].Weight < 50)
    //            {
    //                Console.WriteLine(myClass.Students[i].Name + "体重合格");
    //                myClass.Students.RemoveAt(i);
    //            }
    //        }
    //        if (myClass.Students.Count == 0)
    //        {
    //            timer.Dispose();
    //        }
    //    }

        private static Timer timer;

    //    private static MyClass myClass = new MyClass();
    //}

    //class Student1
    //{
    //    private string name;

    //    public string Name
    //    {
    //        get { return name; }
    //        set { name = value; }
    //    }
    //    private int height;

    //    public int Height
    //    {
    //        get { return height; }
    //        set { height = value; }
    //    }
    //    private int weight;

    //    public int Weight
    //    {
    //        get { return weight; }
    //        set { weight = value; }
    //    }
    //}

    //class Field : Singleton<Field>
    //{
    //    public void DoSport(Student1 student)
    //    {
    //        student.Weight--;
    //    }
    //}

    //class MyClass
    //{
    //    public MyClass()
    //    {
    //        for (int i = 0; i < students.Capacity; i++)
    //        {
    //            Student1 student = new Student1();
    //            student.Name = r.Next().ToString();
    //            student.Height = r.Next(150, 181);
    //            student.Weight = r.Next(50, 71);
    //            students.Add(student);
    //        }
    //    }

    //    private Random r = new Random();

    //    private List<Student1> students = new List<Student1>(50);

    //    public List<Student1> Students
    //    {
    //      get { return students; }
    //      set { students = value; }
    //    }

    }
}
